package com.yogee.topseller.activity.tianyan;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.yogee.core.http.listener.HttpOnNextListener;
import com.yogee.core.http.subscribers.BaseSubscriber;
import com.yogee.core.utils.ToastUtils;
import com.yogee.topseller.R;
import com.yogee.topseller.activity.base.HttpActivity;
import com.yogee.topseller.adapter.BzxrAdapter;
import com.yogee.topseller.bean.BzxrBean;
import com.yogee.topseller.bean.DetailBean;
import com.yogee.topseller.http.HttpManager;
import com.yogee.topseller.layout.TitleLayout;
import com.yogee.topseller.utils.AppUtil;
import com.yogee.topseller.view.EmptyRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class SxrDetailActivity extends HttpActivity {

    @BindView(R.id.add_card_titlelayout)
    TitleLayout titlelayout;
    @BindView(R.id.rv_detail)
    EmptyRecyclerView rv_detail;
    @BindView(R.id.id_empty_view)
    View id_empty_view;
    @BindView(R.id.iv_empty)
    ImageView iv_empty;
    BzxrAdapter detailAdapter = null;
    List<DetailBean> list = new ArrayList<>();

    private String type = "";
    private String companyId="";
    String cmpanyType="";
    private String proId = "";
    @Override
    protected int getLayoutId() {
        return R.layout.activity_detail_bzxr;
    }

    @Override
    protected void initView() {
        titlelayout.setActivity(this);
        titlelayout.setTitle(getIntent().getStringExtra("title"));
        cmpanyType = getIntent().getStringExtra("cmpanyType");
        type =  getIntent().getStringExtra("type");
        companyId = getIntent().getStringExtra("companyId");
        proId = getIntent().getStringExtra("proId");
        rv_detail.setLayoutManager(new LinearLayoutManager(this));
        detailAdapter = new BzxrAdapter(this);
        rv_detail.setAdapter(detailAdapter);
        iv_empty.setImageResource(R.drawable.nodata1);
        rv_detail.setEmptyView(id_empty_view);
//        ToastUtils.showToast(SxrDetailActivity.this,"无数据");
//        initBzxr();
    }

    private void initBzxr(){
        HttpManager.getInstance().eyeCheckBzxr(companyId,type, AppUtil.getUserId(SxrDetailActivity.this),cmpanyType,proId).compose(this.bindRecycler()).subscribe(new BaseSubscriber(new HttpOnNextListener<BzxrBean>() {
            @Override
            public void onNext(BzxrBean o) {
                if(o.getEyeCheck().getError_code()==0){
                    detailAdapter.addData(o.getEyeCheck().getResult().getItems());
                }else{
                    ToastUtils.showToast(SxrDetailActivity.this,o.getEyeCheck().getReason());
                }

            }
        }, this));
    }

}
